﻿using System.Linq;
using System.Web.Mvc;
using Willow.Authorization;
using Willow.IService.Auth;
namespace Willow.WebApplication
{
    public class ModuleConfig
    {
        public static void Init()
        {
            var moduleService = DependencyResolver.Current.GetService<IModuleService>();
            var modules = moduleService.Filter(p => p.IsDelete == false)
                .Select(p => new LoginModule
                {
                    Id = p.Id,
                    Name = p.Name,
                    ParentId = p.ParentId,
                    URL = p.URL,
                    DisplayOrder = p.DisplayOrder.HasValue ? p.DisplayOrder.Value : 0
                }).ToList();
            GlobalModule.Instance.Init(modules);
        }
    }
}